# -*- coding: utf-8 -*-
"""配置文件"""
import logging
from redis import StrictRedis


class Config(object):
    # 设置密钥
    SECRET_KEY = 'ajdasndsajjjjjjjjjjjjjjjjjjjjjjjjjdasn dam,d ass,dada da'
    """数据库配置信息"""
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@localhost:3306/information'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 当视图函数执行数据库的修改操作后自动commit
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    """redis配置"""
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    """session保存位置"""
    SESSION_TYPE = 'redis'
    # 由于session的加密，此处不能设置decode_responses为True，否则加密后的数据解码就会报错
    # SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT,decode_responses=True)
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)

    # session签名
    SESSION_USE_SIGNER = True
    # 设置session过期时间(2天)
    SESSION_PERMANENT = False
    PERMANENT_SESSION_LIFETIME = 86400
    # 日志等级配置
    LOG_LEVEL = logging.DEBUG


class DevelopmentConfig(Config):
    """开发环境"""
    DEBUG = True


class ProductionConfig(Config):
    """生产环境"""
    DEBUG = False
    LOG_LEVEL = logging.WARNING


class TestingConfig(Config):
    """测试环境"""
    DEBUG = True
    TESTING = True


configDict = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'testing': TestingConfig
}
